/**
 * @author KujoMiva
 * @name userAccount.js
 * @desc 用户账户接口
 * @time 2020年05月14日 23:54:24 星期四
 */
import request from '@/utils/axios';

export function register({ account, password, verifyCode, nickname }) {
    return request({
        url: '/register',
        method: 'POST',
        data: { account, password, verifyCode, nickname },
    });
}

export function login({ account, password, verifyCode, actionType }) {
    return request({
        url: '/login',
        method: 'POST',
        data: { account, password, verifyCode, actionType },
    });
}

export function logout(client) {
    return request({
        url: '/logout',
        method: 'DELETE',
        data: { client },
    });
}

export function userInfo(uid) {
    return request({
        url: '/user/info',
        method: 'GET',
        params: { uid },
    });
}

export function resetInfo({ nickname, gender, birthday, sign }) {
    return request({
        url: '/user/reset/info',
        method: 'PUT',
        data: { nickname, gender, birthday, sign },
    });
}

export function resetPassword({ account, verifyCode, newPassword }) {
    return request({
        url: '/user/reset/password',
        method: 'PUT',
        data: { account, verifyCode, newPassword },
    });
}
/**
 *  上传头像接口
 * @param {FIle} file 新头像
 */
export function uploadAvatar(file) {
    const formData = new FormData();
    formData.append('avatar', file);
    return request({
        url: '/user/uploader/avatar',
        method: 'PUT',
        data: formData,
    });
}
